from django.urls import path
from . import views
import datetime

app_name = 'catalog'

# 路径
urlpatterns = [
    path('', views.index, name='index'),
    path('books/', views.BookListView.as_view(), name='books'),
    path('book/<int:pk>', views.book_detail_view, name='book-detail'),
    # re_path(r'^book/(?P<pk>\d+)$', views.BookDetailView.as_view(), name='book-detail'),
    # path('url/', views.my_reused_view, {'my_template_name': 'some_path'}, name='aurl'),
    # path('anotherurl/', views.my_reused_view, {'my_template_name': 'another_path'}, name='anotherurl'),
    path('authors/', views.AuthorListView.as_view(), name='authors'),
    path('author/<int:pk>', views.AuthorDetailView.as_view(), name='author-detail'),
]

urlpatterns += [
    path('mybooks/', views.LoanedBooksByUserListView.as_view(), name='my-borrowed'),
    path('borrowed/', views.BorrowedBooksListView.as_view(), name='all-borrowed'),
    path('book/<uuid:pk>/renew/', views.renew_book_librarian, name='renew-book-librarian'),
]

urlpatterns += [
    path('author/create/', views.AuthorCreate.as_view(), name='author_create'),
    path('author/<int:pk>/update/', views.AuthorUpdate.as_view(), name='author_update'),
    path('author/<int:pk>/delete/', views.AuthorDelete.as_view(), name='author_delete'),
]

urlpatterns += [
    path('book/create/', views.BookCreate.as_view(), name='book_create'),
    path('book/<int:pk>/update/', views.BookUpdate.as_view(), name='book_update'),
    path('book/<int:pk>/delete/', views.BookDelete.as_view(), name='book_delete'),
]

urlpatterns += [
    path('ranking/', views.book_borrow_ranking, name='book-borrow-ranking'),
]

urlpatterns += [
    path('book/<int:pk>/like/', views.like_book, name='like-book'),
    path('book/<int:pk>/unlike/', views.unlike_book, name='unlike-book'),
    path('book/<int:pk>/favorite/', views.favorite_book, name='favorite-book'),
    path('book/<int:pk>/unfavorite/', views.unfavorite_book, name='unfavorite-book'),
]

urlpatterns += [
    path('my-favorites/', views.my_favorites, name='my-favorites'),
]

urlpatterns += [
    path('favorite-groups/', views.manage_favorite_groups, name='manage-favorite-groups'),
    path('favorite-groups/<int:pk>/delete/', views.delete_favorite_group, name='delete-favorite-group'),
    path('favorite-groups/<int:pk>/rename/', views.rename_favorite_group, name='rename-favorite-group'),
    path('favorite-groups/<int:pk>/move/<str:direction>/', views.move_favorite_group, name='move-favorite-group'),
    path('favorite-groups/public/<uuid:uuid>/', views.public_favorite_group, name='public-favorite-group'),
]

urlpatterns += [
    path('book/<int:pk>/rate/', views.rate_book, name='rate_book'),
    path('ai-chat/', views.ai_chat_view, name='ai_chat'),
    path('ai-chat/clear_history/', views.clear_chat_history, name='clear_chat_history'),
]

# New URL patterns for Review interactions
urlpatterns += [
    path('review/<int:pk>/like/', views.like_review, name='like_review_comment'),
    path('review/<int:pk>/unlike/', views.unlike_review, name='unlike_review_comment'),
    path('review/<int:pk>/favorite/', views.favorite_review, name='favorite_review_comment'),
    path('review/<int:pk>/unfavorite/', views.unfavorite_review, name='unfavorite_review_comment'),
    path('review/<int:pk>/comment/', views.comment_review, name='comment_review'),
]

urlpatterns += [
    path('my-favorites/export/csv/', views.export_favorites_csv, name='export_favorites_csv'),
    path('my-favorites/export/excel/', views.export_favorites_excel, name='export_favorites_excel'),
]

urlpatterns += [
    path('profile/edit/', views.profile_edit, name='profile_edit'),
]

urlpatterns += [
    path('statistics/', views.book_statistics_view, name='book_statistics'),
]

urlpatterns += [
    path('book/<uuid:pk>/borrow/', views.borrow_book, name='borrow-book'),
    path('book/<uuid:pk>/return/', views.return_book, name='return-book'),
]


